package com.cn.wanxi.service;

import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.model.NewsModel;

import java.util.ArrayList;
import java.util.List;

public class NewsService {
    public List<NewsModel> getNewsModelList() {
        List<NewsModel> newsModelList = new ArrayList<>();//定义一个集合的空间
        NewsModel newsModel = new NewsModel();
        String[] titles = newsModel.titles;
        String[] contents = newsModel.contents;//静态赋值
        String[] hrefs = newsModel.hrefs;//动态赋值
        for (int i = 0; i < titles.length; i++) {
            NewsModel model = new NewsModel();
            model.setHref(hrefs[i]);
            model.setContent(contents[i]);
            model.setTitle(titles[i]);
            newsModelList.add(model);//添加导航对象
        }
        return newsModelList;
    }
}
